/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.core;

import org.eclipse.emf.ecore.EClass;
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.xml.XMLUtility;

/**
 * @author zl
 *
 */
public class MetaComment extends MetaModelElement {	
	protected static final String BODY_DEFAULT = "";	
	protected String body = BODY_DEFAULT;

	@MethodProperty(
			id = "COMMENT_BODY",
			catalog = "Model",
			name = CorePackage.COMMENT_BODY,
			setter = "setBody"
			)
	public String getBody() {
		return body;
	}

	public void setBody(String newBody) {
		String oldBody = body;
    	body = newBody;
    	firePropertyChange(CorePackage.COMMENT_BODY, oldBody, newBody);
	}
	
	public void serialize(Element root) {
		super.serialize(root);
		XMLUtility.xmlInstance.serializeAttribute(root, CorePackage.COMMENT_BODY, body);
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		body = XMLUtility.xmlInstance.deSerializeString(root, CorePackage.COMMENT_BODY);
	}
	
	@Override
	protected EClass eStaticClass() {
		return EMetaModelPackage.Literals.EMETA_COMMENT;
	}
	
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case EMetaModelPackage.EMETA_COMMENT__BODY:
				return getBody();
		}
		return super.eGet(featureID, resolve, coreType);
	}
}
